<%@page import="java.util.ArrayList"%>
<%@page import="entity.Student"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Student.jsp</title>
<link rel="stylesheet" type="text/css"
	href="bootstrap-3.3.7-dist/css/bootstrap.css" />
<style type="text/css">
form {
	display: inline;
}
</style>
</head>
<body>
	<form class="line"
		action="<%=request.getContextPath()%>/student?method=search"
		method="post">
		名字：<input type="text" name="searchName" /> <input type="submit"
			value="搜索" class="btn btn-info" />
	</form>
	<a href="<%=request.getContextPath()%>/student_insert.jsp"
		class="btn btn-success line">添加</a>
	<table
		class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<td>ID</td>
			<td>名字</td>
			<td>年龄</td>
			<td>性别</td>
			<td>删除</td>
			<td>修改</td>
		</tr>
		<%
			ArrayList<Student> list = (ArrayList<Student>)request.getAttribute("list");
			for (Student student : list) {
		%>
		<tr>
			<td><%=student.getStudent_id()%></td>
			<td><%=student.getStudent_name()%></td>
			<td><%=student.getStudent_age()%></td>
			<td><%=student.getGender()%></td>
			<td><a class="btn btn-danger" href="javascript:void(0)"
				onclick="deleteById(<%=student.getStudent_id()%>)">删除</a></td>
			<td><a class="btn btn-warning"
				href="<%=request.getContextPath()%>/student?method=toUpdate&student_id=<%=student.getStudent_id()%>">修改</a></td>
		</tr>
		<%
			}
		%>
	</table>
	<script type="text/javascript">
		function deleteById(id){
			var isDel = confirm("您确认要删除吗？");
			if(isDel){
				location.href="/ST_JavaEE/student?method=deleteById&id=" + id;
			}
		}

	</script>
</body>
</html>